<!DOCTYPE html>
<html lang="en">
  <head>
    <title><%= defined?(@page_title) ? "#{@page_title} // " : "" %>Flipper</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="stylesheet" href="<%= script_name + bootstrap_css[:src] %>" integrity="<%= bootstrap_css[:hash] %>" crossorigin="anonymous">
    <link rel="stylesheet" href="<%= script_name %>/css/application.css">
  </head>
  <body class="py-4">
    <div class="container mw-600">
      <%- unless Flipper::UI.configuration.banner_text.nil? -%>
        <div class="alert alert-<%= Flipper::UI.configuration.banner_class %> text-center fw-bold">
          <%== Sanitize.fragment(Flipper::UI.configuration.banner_text, Sanitize::Config::BASIC) %>
        </div>
      <%- end -%>

      <div class="text-muted small text-end">
        <a href="#" class="badge text-bg-warning ms-2 d-none" style="font-size:100%" id="new-version-badge" data-version="<%= Flipper::VERSION %>">
        </a>

        <% if Flipper.deprecated_ruby_version? %>
          <a href="https://github.com/flippercloud/flipper/pull/776" class="badge text-bg-danger ms-2" style="font-size:100%">
            Ruby <%= RUBY_VERSION %> deprecated
          </a>
        <% end %>

        <% if defined?(Rails) && Flipper::Engine.deprecated_rails_version? %>
          <a href="https://github.com/flippercloud/flipper/pull/776" class="badge text-bg-danger ms-2" style="font-size:100%">
            Rails <%= Rails.version %> deprecated
          </a>
        <% end %>
      </div>
      <nav>
        <ul class="nav nav-underline mb-3 align-items-center">
          <% if Flipper::UI.configuration.application_href %>
            <li class="nav-item">
              <a class="nav-link" href="<%= Flipper::UI.configuration.application_href %>">
                ‹ App
              </a>
            </li>
          <% end %>


          <% Flipper::UI.configuration.nav_items.each do |item| %>
            <li class="nav-item">
              <a href="<%= url_for(item[:href]) %>" class="nav-link<%= " active" if request.url.start_with?(url_for(item[:href])) %>">
                <%= item[:title] %>
              </a>
            </li>
          <% end %>

          <li class="nav-item ms-auto text-muted small">
            <a href="https://www.flippercloud.io/docs/ui?utm_source=oss&utm_medium=ui&utm_campaign=docs">Docs</a>
            &bull;
            Version: <%= Flipper::VERSION %>
          </li>
        </ul>
      </nav>

      <div>
        <%== yield %>
      </div>

      <% if Flipper::UI.configuration.cloud_recommendation %>
        <div class="d-flex justify-content-center mt-5">
          <div class="row" style="max-width: 350px;">
            <div class="col-auto d-flex align-items-center">
              <a href="https://www.flippercloud.io/?utm_source=oss&utm_medium=ui&utm_campaign=spread_the_love">
                <img src="<%= script_name %>/images/logo.png" width="50" />
              </a>
            </div>
            <div class="col text-muted p-0">
              <small>For audit history, rollback, finer-grained permissions, and multi-environment sync check out <a href="https://www.flippercloud.io/?utm_source=oss&utm_medium=ui&utm_campaign=spread_the_love">Flipper&nbsp;Cloud</a>. We even have a free tier!</small>
            </div>
          </div>
        </div>
      <% end %>
    </div>

    <script src="<%= script_name + popper_js[:src] %>" integrity="<%= popper_js[:hash] %>" crossorigin="anonymous"></script>
    <script src="<%= script_name + bootstrap_js[:src] %>" integrity="<%= bootstrap_js[:hash] %>" crossorigin="anonymous"></script>
    <script src="<%= script_name %>/js/application.js?v=<%= Flipper::VERSION %>"></script>
    <script src="<%= script_name %>/js/version.js?v=<%= Flipper::VERSION %>"></script>
  </body>
</html>
